home *** CD-ROM | disk | FTP | other *** search
- /* UUEncode.thor · by Troels Walsted Hansen
- ** $VER: UUEncode.thor v1.43 (19.03.94)
- **
- ** An ARexx script that uuencodes a file and either places it in the
- ** clipboard or posts a message for you containing the file. Using
- ** LhA, this script will archive the file if it isn't already.
- **
- ** Utilises uuIn by Nicolas Dade, MagicClip by Franz Schwarz
- ** and LhA by Stefan Boberg.
- **
- ** Known to be work with uuIn v1.03, MagicClip v1.2 and LhA 1.38.
- */
-
- /* some user varibles. edit to your hearts content */
-
- tmpdir = "T:" /* Work dir for the encoding */
-
- /* this is where the action begins.. */
-
- options results
-
- if(substr(address(),1,4) ~= "THOR") then do
- parse arg portname
- if~(show(p, portname)) then do
- if ~(show(p, "THOR.01")) then do
- say "No THOR port found!"
- exit
- end
- else portname = "THOR.01"
- end
- end
- else portname = address()
-
- address(portname)
-
- if ~show(l, 'rexxsupport.library') then do
- if ~addlib('rexxsupport.library', 0, -30) then do
- say "Please install rexxsupport.library in your libs: directory"
- exit
- end
- end
-
- /* main stuff */
-
- GETGLOBALCONFIG
- THORTOFRONT
- REQUESTFILE TITLE '"Select file to encode:"' ID '"'GLOBALCONFIG.UPLOADPATH'"' FP PAT '"#?"'
-
- filetoencode = result
- lastchar = right(filetoencode,1)
-
- if(rc~=0|lastchar = "/"|lastchar = ":"|filetoencode = "") then do
- REQUESTNOTIFY TEXT '"No file selected!"' BT '"_Ok"'
- call CleanUp()
- end
-
- posi = lastpos("/",FileToEncode)
- if(posi = 0) then posi = lastpos(":",FileToEncode)
- WithoutPath = substr(FileToEncode,posi+1)
-
- /* if file isn't LhA'ed -- do it ourselves */
-
- extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
-
- if~(extension = "LHA" | extension = "LZH") then do
- REQUESTNOTIFY TEXT '"Do you want to LhA the file?"' BT '"_Yes|_No"'
- if(result) then do
- address command "LhA -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
- FileToEncode = tmpdir||WithoutPath||".lha"
- end
- end
-
- address command "uuIn INFILE="||'"'filetoencode'"'||" OUTFILE="||tmpdir||"Message.uu"
-
- if ~exists(tmpdir"Message.uu") then do
- REQUESTNOTIFY TEXT '"File containing uuencoded data not found."' BT '"_Ok"'
- call CleanUp()
- end
-
- REQUESTNOTIFY TEXT '"Place in clipboard or post as a message?"' BT '"Clip_board|_Post|_Cancel"'
- choice = result
-
- if(choice = 1) then address command "MagicClip >nil: FILE="tmpdir"Message.uu"
- else if(choice = 2) then do
- REQUESTLIST BBSLIST
- bbsname = result
- if(rc ~= 0|bbsname = "") then break
-
- REQUESTLIST CONFLIST BBS '"'bbsname'"'
- confname = result
- if(rc ~= 0) then break
-
- REQUESTSTRING TITLE '"Please enter subject of message:"' BT '"_Ok|_Cancel"' ID WithoutPath MAXCHARS 100
- subject = result
- if(rc ~= 0|subject = "") then break
-
- REQUESTSTRING TITLE '"Please enter receiver name:"' BT '"_Ok|_Cancel"' ID '"ALL"' MAXCHARS 100
- receiver = result
- if(rc ~= 0|receiver = "") then break
-
- ADDEVENT BBS '"'bbsname'"' EVENT ENTERMSG SENDTO '"'receiver'"' CONF '"'confname'"' MSGFILE tmpdir"Message.uu" SUB '"'subject'"'
- if(rc ~= 0) then REQUESTNOTIFY TEXT '"Failed to post message!"' BT '"_Ok"'
- else PACKEVENTS '"'bbsname'"'
- end
-
- call CleanUp()
-
- /* cleanup and exit */
-
- CleanUp:
- if(exists(tmpdir||WithoutPath||".lha")) then call delete(tmpdir||WithoutPath||".lha")
- if(exists(tmpdir||"Message.uu")) then call delete(tmpdir"Message.uu")
- exit
- return
-